package com.lyz.common;
//返回结果类

import lombok.Data;

@Data
public class Result {

    private int code;//状态码:200为成功，400为失败
    private String message;//返回信息,成功/失败
    private Long total;//总记录数
    private Object data;//数据
    private String msg;

//    public String getMsg() {
//        return msg;
//    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public static Result fail() {
        return fail("操作失败");
    }

    public static Result fail(String message) {
        Result result = new Result();
        result.setCode(500);
        result.setMsg(message);
        return result;
    }

    public static Result success()
    {
        return result(200,"成功",0L,null);
    }

    public static Result success(Object data)
    {
        return result(200,"成功",0L,data);
    }
    public static Result sucess(Object data,Long total)
    {
        return result(200,"成功",total,data);
    }
    private static Result result(int code,String message,Long total,Object data)
    {
        Result r = new Result();
        r.setData(message);
        r.setMessage(message);
        r.setTotal(total);
        r.setData(data);
        return r;
    }

}
